package j03liu;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;

public class J1 {
    public static void main(String[] args) throws Exception {
        FileInputStream fs = new FileInputStream("_0905/src/j03liu/1.txt");
//        System.out.println((char) fs.read());//a
//        System.out.println(fs.read());
//        System.out.println(fs.read());
//
//        System.out.println((char) fs.read());
//        System.out.println(fs.read());
//        System.out.println(fs.read());
//
//        System.out.println(fs.read());
//        System.out.println(fs.read());
//        System.out.println(fs.read());
//        System.out.println(fs.read());
        System.out.println("====");
        byte[] bArr = new byte[2];
        fs.skip(2);
        fs.read(bArr);
        System.out.println("bArr = " + Arrays.toString(bArr));
        fs.read(bArr);
        System.out.println("bArr = " + Arrays.toString(bArr));
        fs.close();
    }
}

class J2{
    public static void main(String[] args) {
        FileInputStream fs = null;
        try {
            fs = new FileInputStream("_0905/src/j03liu/1.txt");
            System.out.println("fs.read() = " + fs.read());
//            fs.close();
        } catch (FileNotFoundException e) {
//            try {
//                fs.close();
//            } catch (IOException ex) {
//                throw new RuntimeException(ex);
//            }
            throw new RuntimeException(e);
        } catch (IOException e) {
//            try {
//                fs.close();
//            } catch (IOException ex) {
//                throw new RuntimeException(ex);
//            }
            throw new RuntimeException(e);
        } finally {
            try {
                fs.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}